﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZX.OA.Model;
namespace ZX.OA.DAL
{
    /// <summary>
    /// 会议室的操作
    /// </summary>
 public    class MeetingRoomDal
 { /// <summary>
     /// EF的链接
     /// </summary>
     Entity entity = new Entity();
     /// <summary>
     /// 会议室列表的显示
     /// </summary>
     /// <returns></returns>
     public List<MeetingRoomInfo> Show_MeetingRoomInfo()
     {
         return entity.MeetingRoomInfo.ToList();
     }

     /// <summary>
     /// 添加会议室信息
     /// </summary>
     /// <param name="id"></param>
     /// <returns></returns>
     public int Add_MeetingRoomInfo(MeetingRoomInfo room)
     {
         entity.MeetingRoomInfo.Add(room);
         return entity.SaveChanges();
     }
     /// <summary>
     /// 显示会议室详情
     /// </summary>
     /// <param name="id"></param>
     /// <returns></returns>
     public MeetingRoomInfo Upd_MeetingRoomInfo(int id)
     {
         return entity.MeetingRoomInfo.Find(id);
     }
     /// <summary>
     /// 撤销会议室信息
     /// </summary>
     /// <param name="id"></param>
     /// <returns></returns>
     public int Del_MeetingRoomInfo(int id)
     {
         entity.MeetingRoomInfo.Remove(entity.MeetingRoomInfo.Find(id));
         return entity.SaveChanges();

     }
     /// <summary>
     /// 查询会议室信息
     /// </summary>
     /// <param name="MeetingRoomName">会议室名称</param>
     /// <returns></returns>
     public List<MeetingRoomInfo> Sel_MeetingRoomInfo(string MeetingRoomName )
     {
       return   entity.MeetingRoomInfo.Where(p => (string.IsNullOrEmpty(MeetingRoomName)) ? true : p.MeetingRoomName.Contains(MeetingRoomName)).ToList();
     }
    
    }
}
